package com.ibangnuo.manage.controller.shop;

import com.ibangnuo.api.employee.MerchantsControllerApi;
import com.ibangnuo.framework.domain.request.employee.EmployeeRequest;
import com.ibangnuo.framework.domain.request.shop.ShopRequest;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.manage.service.shop.MerchantsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author:ly
 * @Data:2019/12/31 14:07
 * @Verdion:1.0
 */
@RestController
@RequestMapping("/merchantsEntity")
public class MerchantsController implements MerchantsControllerApi {


    @Autowired
    private MerchantsService shopService;

    @Override
    @PostMapping("/merchantsQuery")
    public QueryResponseResult query(@RequestBody Map employeeRequest) {
        return shopService.query(employeeRequest);
    }

    @Override
    @GetMapping("/delMerchants/{merchantsUuid}")
    public QueryResponseResult delMerchants(@PathVariable("merchantsUuid") String merchantsUuid) {
        return shopService.delMerchants(merchantsUuid);
    }

    @PostMapping("/addMerchants")
    @Override
    public QueryResponseResult addMerchants(@RequestBody Map employeeRequest) {
        return shopService.addMerchants(employeeRequest);
    }

    @Override
    @PostMapping("/upMerchants")
    public QueryResponseResult upMerchants(@RequestBody Map map) {
        return shopService.upMerchants(map);

    }

    @Override
    @GetMapping("/findById/{merchantsUuid}")
    public QueryResponseResult findById(@PathVariable("merchantsUuid") String id) {
       return shopService.findById(id);
    }

    @Override
    @GetMapping("/shopName")
    public QueryResponseResult selectShopName() {
        return shopService.selectShopName();
    }

    /**
     * 新版添加门店，多添加
     * @param shopRequest
     * @return
     */
    @PostMapping("/addNew")
    @Override
    public ObjectResult addNew(@RequestBody ShopRequest shopRequest) {
        return shopService.addNew(shopRequest);
    }

    /**
     * 依据商家id查询门店
     * @param commercialId
     * @return
     */
    @GetMapping("/findByCommercialIdNew/{commercialId}")
    @Override
    public ObjectResult findByCommercialIdNew(@PathVariable("commercialId") String commercialId) {
        return shopService.findByCommercialIdNew(commercialId);
    }


}
